<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>

<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <base href="<%=basePath%>">

    <title>体检人员注册</title>
    <link href="../static/css/sign-in.css" rel="stylesheet">
    <script src="<%=basePath%>static/js/jquery.js" type="text/javascript"></script>
    <script src="<%=basePath%>static/js/pintuer.js" type="text/javascript"></script>
    <script type="text/javascript" src="<%=basePath%>static/js/jquery-3.5.0.js"></script>
    <script src="<%=basePath%>static/lib/layui/layui.js" charset="utf-8" type="text/javascript"></script>
    <script type="text/javascript" src="<%=basePath%>static/js/xadmin.js"></script>
</head>
<body>
<div class="div_top_1">
</div>
<div class="main">
    <div class="login">
        <div class="div_top_2">

        </div>
        <div class="div_login_head">
            体检人员注册
        </div>

        <div class="div_empty">
        </div>
        <form action="" method="post">
            <div class="div_input_account">
                <input class="input_account" type="text" name="userName" id="username" placeholder="用户名"/>
            </div>
            <div class="div_empty">
            </div>

            <div class="div_input_pwd">
                <input class="input_pwd" type="password" name="password" id="password" placeholder="密码"/>
            </div>

            <div class="div_input_pwd">
                <input class="input_pwd" type="hidden" name="role" id="role" placeholder="角色" value="群众"/>
            </div>
            <div class="div_empty">
            </div>

            <div class="div_button_login">
                <input class="button_login" type="button" value="注册" onclick="signIn()"/>
            </div>
        </form>
    </div>
</div>

<script>
    function signIn() {
        $.ajax({
            url:"../role/signIn",
            dataType:"json",
            type:"post",
            data:{
                "username":$("#username").val(),
                "password":$("#password").val(),
                "role":$("#role").val(),
            },success:function (data) {
                if(data.code == "error"){
                    alert("用户已存在");
                }else if (data.code == "succeed"){
                    alert("注册成功并跳转到登录界面")
                    parent.location.href = '../sys/returnLogin';
                }
            },error:function () {
                alert("操作错误");
            }
        })
    }
</script>

</body>
</html>